import { getCookie } from './tools.js';

$(document).on('click', '.address1 span', function () {
    $('.address_pane').css('display','block')
})


$(document).on('click', '.a', function () {
    $('.address_pane').css('display', 'none')
})

$(document).on('click', '.a1', function () {
    console.log($('.inp').val());
    console.log($('.inp1').val());
    console.log($('.inp2').val());
    console.log($('.inp3').val());
    console.log($('.inp4').val());
    var a = $('.inp').val()
    var b = $('.inp1').val()
    var c = $('.inp2').val()
    var d = $('.inp3').val()
    var e = $('.inp4').val()
    var qq = a + b + c + d + e
    console.log(qq);
})


$(document).on('click', '.lili',function () {
    // $('.show').css('display', 'block')
    $('.sss').show()
})



var list = [
    {
        uid: '01',
        name: '上海',
        children: [
            {
                uid: '0101',
                name: '宝山区'
            },
            {
                uid: '0102',
                name: '长宁区'
            },
            {
                uid: '0103',
                name: '黄浦区'
            },
            {
                uid: '0104',
                name: '虹口区'
            },
            {
                uid: '0105',
                name: '奉贤区'
            },
            {
                uid: '0106',
                name: '静安区'
            },
            {
                uid: '0107',
                name: '闵行区'
            },
            {
                uid: '0108',
                name: '浦东新区'
            },
            {
                uid: '0109',
                name: '普陀区'
            },
            {
                uid: '0110',
                name: '青浦区'
            },

        ]
    },
    {
        uid: '02',
        name: '北京',
        children: [
            {
                uid: '0201',
                name:'昌平区'
            },
            {
                uid: '0202',
                name: '朝阳区'
            },
            {
                uid: '0203',
                name: '崇文区'
            },
            {
                uid: '0204',
                name: '大兴区'
            },
            {
                uid: '0205',
                name: '东城区'
            },
            {
                uid: '0206',
                name: '房山区'
            },
            {
                uid: '0207',
                name: '丰台区'
            },
            {
                uid: '0208',
                name: '海淀区'
            }
        ]
    },
    {
        uid: '03',
        name: '天津',
        children: [
            {
                uid: '0301',
                name: '北辰区'
            },
            {
                uid: '0302',
                name: '东丽区'
            },
            {
                uid: '0303',
                name: '和平区'
            },
            {
                uid: '0304',
                name: '河北区'
            },
            {
                uid: '0305',
                name: '河东区'
            },
            {
                uid: '0306',
                name: '河西区'
            },
            {
                uid: '0307',
                name: '红桥区'
            },
            {
                uid: '0308',
                name: '津南区'
            }
        ]
    },
    {
        uid: '04',
        name: '杭州',
        children: [
            {
                uid: '0401',
                name: '滨江区'
            },
            {
                uid: '0402',
                name: '拱墅区'
            },
            {
                uid: '0403',
                name: '江干区'
            },
            {
                uid: '0404',
                name: '上城区'
            },
            {
                uid: '0405',
                name: '西湖区'
            },
            {
                uid: '0406',
                name: '下城区'
            },
            {
                uid: '0407',
                name: '下沙区'
            },
            {
                uid: '0408',
                name: '萧山区'
            }
        ]
    }
];

var html = '<option value="">城市</option>';
list.forEach(({ uid, name }) => {
    html += `<option value="${uid}">${name}</option>`;
})
$('#sel').html(html)

$(document).on('change', '#sel', function () {
    
    var provinceId = this.value;
    // console.log(this.value);
    var province = list.filter(({ uid }) => uid === provinceId)[0];
    console.log(province[`name`]);
    var qu = province.children;
    console.log(qu);
    var html = ''
    qu.forEach(({ name }) => {
        html += `<a href="#" id="sp">${name}</a>`
    })
    $('.cont').html(html)


    $(document).on('click', '.cont a', function (e) {
        var html = province[`name`] + e.target.text       
        // console.log(html);
        $('.inp').val(html)
        // $('.show').css('display', 'none')
        // $('.sss').hide()
        $('.sss').slideToggle()
    })

})





layui.use('laydate', function () {
    var laydate = layui.laydate;

    //执行一个laydate实例
    laydate.render({
        elem: '#test1' //指定元素
    });

    laydate.render({
        elem: '#test'
        , type: 'time'
        
        // , range:' 0~24'
    });
});